<?php

namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;

class User extends Model
{

    use HasApiTokens, HasFactory, Notifiable;
    protected $table = 'user';
    public $timestamps = false;

    public static function find($msg_form)
    {
        return self::where('id', $msg_form)->first();
    }


    public function room(): BelongsTo
    {

        return $this->belongsTo(room::class);
    }

    /**
     * 创建时间
     * @return Attribute
     */
    protected function createTime(): Attribute
    {
        return Attribute::make(
            get: fn($value) => \date('Y-m-d H:i:s', $value),
        );

    }

    /**
     * 更新时间。
     *
     * @return Attribute
     */
    protected function updateTime(): Attribute
    {
        return Attribute::make(
            get: fn($value) => \date('Y-m-d H:i:s', $value),
        );
    }


}
